package org.jeecg.modules.flowable.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.flowable.dto.FlowTaskOperationDTO;
import org.jeecg.modules.flowable.query.FlowTaskQuery;
import org.jeecg.modules.flowable.service.FlowTaskService;
import org.jeecg.modules.flowable.vo.FlowTaskVO;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "流程任务管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/flow/task")
public class FlowTaskController {

    final FlowTaskService flowTaskService;

    @ApiOperation(value = "获取待办列表")
    @PostMapping(value = "/todo/list")
    public Result<Page<FlowTaskVO>> todoList(@RequestBody FlowTaskQuery query) {
        return this.flowTaskService.todoList(query);
    }

    @ApiOperation(value = "审批任务")
    @PostMapping(value = "/complete")
    public Result<Void> complete(@RequestBody FlowTaskOperationDTO operationDTO) {
        return this.flowTaskService.complete(operationDTO);
    }

    @ApiOperation(value = "否决任务（起始点、上一个节点、终止）")
    @PostMapping(value = "/veto")
    public Result<Void> veto(@RequestBody FlowTaskOperationDTO operationDTO) {
        return this.flowTaskService.veto(operationDTO);
    }

}
